package com.suxin.opentsdb.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Classname HelloController
 * @Description [ TODO ]
 * @Author Tang
 * @Date 2020/10/13 21:45
 * @Created by ASUS
 */
@RestController
public class HelloController {

    @GetMapping("/index")
    public String index() throws ExecutionException, InterruptedException {

        FutureTask<String> futureTask = new FutureTask<String>(new Callable<String>() {
            @Override
            public String call() throws Exception {
                System.out.println(Thread.currentThread().getName() + "....");
                return "run...";
            }
        });

        System.out.println(futureTask.get());

        return "index...";
    }

}